package javase.ch02.method;

/**
 * @Desc TODO
 * @Author chenmin
 * @Date 2025/10/30
 *
 * Thread类
 * 1.构造方法
 *   public Thread(Runnable target, String name)
 *
 * 2.静态常量
 * public final static int MIN_PRIORITY = 1;   优先级最小值
 * public final static int NORM_PRIORITY = 5;  默认优先级
 * public final static int MAX_PRIORITY = 10;  优先级最大值
 *
 * 3.常用API方法
 * public final int getPriority()    获取优先级
 * public final void setPriority(int newPriority)  设置优先级
 * public String toString()  输出线程信息 "Thread[" + getName() + "," + getPriority() + "," + group.getName() + "]";
 */
public class PriorityDemo {

    public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            //执行的任务
            System.out.println(Thread.currentThread().getName());
        }, "T1");
        System.out.println(t1+" , "+t1.getPriority());   //Thread[T1,5,main] , 默认优先级5


        Thread t2 = new Thread(() -> {
            //执行的任务
            System.out.println(Thread.currentThread().getName());
        }, "T2");
        t2.setPriority(Thread.MIN_PRIORITY);


        Thread t3 = new Thread(() -> {
            //执行的任务
            System.out.println(Thread.currentThread().getName());
        }, "T3");
        t3.setPriority(Thread.MAX_PRIORITY);

        //启动线程
        t1.start();
        t2.start();
        t3.start();
    }

}
